<?php use_helper('Url') ?>
<?php if (isset($pager)): ?>
  <table cellspacing="0" class="root_table">
    <tbody>
      <tr>
		<?php
			switch ($search_type) {
				case 1: $label = 'Ngày'; $sort_key = 'date';break;
				case 2: $label = 'Tuần'; $sort_key = 'week';break;
				case 3: $label = 'Tháng'; $sort_key = 'month';break;
			}
		?>  
        <th>
			<?php echo link_to_function('<span>'.$label.'</span>', 'sort(\''.$sort_key.'\', 1)') ?>
        </th>
        <th>
           	<?php echo link_to_function('<span>Tên sân</span>','') ?>
        </th>
		 <th>
				<?php echo link_to_function('<span>Số lượng đặt</span>', 'sort(\'orders_count\', 1)') ?>
	      </th>
		<th>
				<?php echo link_to_function('<span>Số lượng đặt thành công</span>', 'sort(\'success_orders_count\', 1)') ?>
	      </th>
		<th>
				<?php echo link_to_function('<span>Quá hạn</span>', 'sort(\'auto_rejected_orders_count\', 1)') ?>
	      </th>
		<th>
				<?php echo link_to_function('<span>Huỷ</span>', 'sort(\'manual_rejected_orders_count\', 1)') ?>
	      </th>
			<th>
					<?php echo link_to_function('<span>Tổng tiền</span>', 'sort(\'total_amount_count\', 1)') ?>
		      </th>
      </tr>

	<?php foreach ($pager->getResults() as $report) :?>
    <tr>
        <td style="text-align:left"><?php echo $report->date  ?></td>
        <td style="text-align:center"><?php echo $report->DtGround->name ?></td>
		<td style="text-align:center"><?php echo $report->orders_count ?></td>
		<td style="text-align:center"><?php echo $report->success_orders_count ?></td>
		<td style="text-align:center"><?php echo $report->auto_rejected_orders_count ?></td>
		<td style="text-align:center"><?php echo $report->manual_rejected_orders_count ?></td>
		<td style="text-align:center"><?php echo $report->total_amount_count ?></td>
    </tr>
  <?php endforeach ?>
    </tbody>
  </table>

  <?php if ($pager->haveToPaginate()): ?>
    <div class="pagination">
      <?php if (!$pager->isFirstPage()): ?>
        <?php echo link_to_function("First page", 'listReload('.$pager->getFirstPage().')', array('class' => 'page')) ?>
        <?php echo link_to_function("Prev", 'listReload('.$pager->getPreviousPage().')', array('class' => 'page')) ?>
      <?php endif ?>

      <?php foreach ($pager->getLinks() as $link): ?>
        <?php if ($link == $pager->getPage()): ?>
          <span class="page selected"><?php echo $link ?></span>
        <?php else: ?>
          <?php echo link_to_function($link, 'listReload('.$link.')', array('class' => 'page')) ?>
        <?php endif ?>
      <?php endforeach ?>

      <?php if (!$pager->isLastPage()): ?>
        <?php echo link_to_function("Next", 'listReload('.$pager->getNextPage().')', array('class' => 'page')) ?>
        <?php echo link_to_function("Last page", 'listReload('.$pager->getLastPage().')', array('class' => 'page')) ?>
      <?php endif ?>
    </div>
  <?php endif ?>
<?php endif ?>